/*  header-comment
/*  file   : /Users/allan/Desktop/workspace/react-hrm-h5/src/actions/welcome/index
/*  author :  
/*  date   : 2017-6-4 18:27:59
/*  last   : 2017-9-2 19:7:30
*/
import { createAction } from "redux-actions";
import fetch from "../../utils/fetch.js";
import { get } from "../../utils/db";
import { getUrlParam } from "../../utils/common";

export const getUser = createAction("WELCOME_GET_USER");

export const fetchUser = () => dispatch => {
  const url = get("isLwp")
    ? "/r/Adaptor/HrmEmployeeInfoVerifyI/"
    : get("baseUrl");
  return fetch(`${url}findEmpStatus`, {
    body: {
      userId: get("userId")
    },
    meta: {
      dipId: 63484
    }
  }).then(res => {
    dispatch(
      getUser({
        isEdit: res.result === -1
      })
    );
    return res;
  });
};
export const startEntry = (params = {}) => () => {
  const url = get("isLwp")
    ? "/r/Adaptor/HrmEmployeeInfoVerifyI/"
    : get("baseUrl");
  return fetch(`${url}startEntryV2`, {
    body: {
      opUserId: getUrlParam("opUserId")
    },
    meta: {
      dipId: 63474,
      showLoading: params.showLoading
    }
  });
};
